import QtQuick
import QtQuick.Controls
import Qt.labs.platform

Window {
    id: root
    width: 660
    height: 494
    minimumWidth: 660
    minimumHeight: 494
    visible: true
    flags: Qt.Window | Qt.FramelessWindowHint

    MessageDialog {
        id: appInfoMessage
        buttons: MessageDialog.Ok
        text: qsTr("使用说明")
        informativeText: qsTr("1. 点击文件-导入图片 导入原图片\n2. 左侧列表选择图像处理模式\n\
3. 左边显示原图片,右边显示处理后图片\n4. 底部设置当前所选模式的各项参数\n\
5. 点击编辑-替换原图 将处理后的图片设置为原图片6. 点击尺寸 选择生成图片的大小\n\
7. 点击文件-保存图片 将处理后图片保存至本地")
    }

    MessageDialog {
        id: appAboutMessage
        buttons: MessageDialog.Ok
        text: qsTr("关于软件")
        informativeText: qsTr("本软件以学习为目的制作\n作者: 我是阿衰")
    }

    CustomHeaderBar {
        id: customHeaderBar
        width: parent.width
        anchors.top: root.top
        height: 34
        leftSideWidth: 200
        rightSideWidth: 100
        titleText: qsTr("Image Edit Tool V1.0")
        color: "#2e2f30"
        z: 10

        onSpinnerBtnFileClicked: function(index) {
            switch(index) {
                case 0: myFile.openImageFile(0); focus = true; break;
                case 1: imgEditView.saveChangedImg(); focus = true; break;
                case 2: focus = true; break;
                default: break;
            }
        }

        onSpinnerBtnEditClicked: function(index) {
            switch(index) {
                case 0: imgEditView.replaceSourceImg(); focus = true; break;
                default: break;
            }
        }

        onSpinnerBtnSizeClicked: function(index) {
            switch(index) {
                case 0: root.width = 660; root.height = 494; focus = true; break;
                case 1: root.width = 820; root.height = 574; focus = true; break;
                case 2: root.width = 1140; root.height = 734; focus = true; break;
                case 3: root.width = 1460; root.height = 894; focus = true; break;
                default: break;
            }
        }

        onSpinnerBtnHelpClicked: function(index) {
            switch(index) {
                case 0: appInfoMessage.open(); focus = true; break;
                case 1: appAboutMessage.open(); focus = true; break;
                default: break;
            }
        }
    }

    ImgEditView {
        id: imgEditView
        width: parent.width
        anchors.top: customHeaderBar.bottom
        anchors.bottom: parent.bottom

        Component.onCompleted: {

        }
    }

}
